using System;
using System.Data;
using DataScripter.Scripting.Compare.DataTables.Structure;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DataScripter.UnitTests.Comparison.DataTables.Structure
{
    [TestClass]
    public class WhenTable2HasOneExtraColumn
    {
        private readonly DataTableStructureComparisonResult _comparisonResult;

        public WhenTable2HasOneExtraColumn()
        {
            DataTable table1 = DataTableFactory.CreateDataTable();
            DataTable table2 = DataTableFactory.CreateDataTable();
            table2.Columns.Add("Def", typeof(string));

            DataTableStructureComparer comparer = new DataTableStructureComparer(table1, table2);
            _comparisonResult = comparer.Compare();
        }

        [TestMethod]
        public void ResultShouldBeNotBeOk()
        {
            Assert.IsFalse(_comparisonResult.IsSame());
        }

        [TestMethod]
        public void ResultShouldHaveExtraColumns()
        {
            Assert.AreEqual(1, _comparisonResult.ColumnsToRemove.Count);
        }

        [TestMethod]
        public void ExtraColumnNameShouldMatch()
        {
            Assert.AreEqual("Def", _comparisonResult.ColumnsToRemove[0]);
        }
    }
}